package com.zsy.petshop_01.controller;

import com.zsy.petshop_01.common.result.ResponseResult;
import com.zsy.petshop_01.model.vo.discount.InsertVo;
import com.zsy.petshop_01.model.vo.discount.UpdateVo;
import com.zsy.petshop_01.service.DiscountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "折扣管理")
@RestController
@RequestMapping("/discount")
public class DiscountController {
    @Autowired
    DiscountService discountService;

    @ApiOperation("搜索所有折扣信息")
    @GetMapping("/selectAll")
    public ResponseResult<?> selectAll() {
        return discountService.selectAll();
    }

    @ApiOperation("搜索折扣信息")
    @GetMapping("/selectByMessage")
    public ResponseResult<?> selectByMessage(@RequestParam(value = "message", required = false) String message) {
        return discountService.selectByMessage(message);
    }

    @ApiOperation("添加折扣信息")
    @PostMapping("/insert")
    public ResponseResult<?> insert(@RequestBody InsertVo insertVo) {
        return discountService.insert(insertVo);
    }

    @ApiOperation("修改折扣信息")
    @PostMapping("/update")
    public ResponseResult<?> update(@RequestBody UpdateVo updateVo) {
        return discountService.update(updateVo);
    }

    @ApiOperation("删除折扣信息")
    @PostMapping("/delete")
    public ResponseResult<?> delete(@RequestParam("id") Integer id) {
        return discountService.delete(id);
    }

}
